package com.aaa.dao.impl;

import com.aaa.dao.BaseDao;
import com.aaa.dao.RecharGerecordDao;
import com.aaa.entity.RecharGereCord;

import java.util.List;

public class RecharGerecordDaoImol implements RecharGerecordDao {
    BaseDao baseDao = BaseDao.getInstance();
    @Override
    public int InsertRecharGerecord(RecharGereCord recharGereCord) {
        String sql = "insert into rechargerecord (cardId,rechargeAmount,afterAmount,beforeAmount,ruleId,createdTime,staffId) values(?,?,?,?,?,?,?)";
        Object[] objects = {recharGereCord.getCardId(),recharGereCord.getRechargeAmount(),recharGereCord.getAfterAmount(),recharGereCord.getBeforeAmount(),
                recharGereCord.getRuleId(), recharGereCord.getCreatedTime(),recharGereCord.getStaffId()};
        return baseDao.executeUpdate(sql,objects);
    }



    @Override
    public int UpdateCardAmount(RecharGereCord recharGereCord) {
        String sql = "UPDATE card set amount=? WHERE cardId = ?";
        Object[] objects = {recharGereCord.getAfterAmount(),recharGereCord.getCardId()};
        return baseDao.executeUpdate(sql,objects);
    }
}
